<form action="" method="post" id="listing_content_form">


<?php $body_content = " "; ?>

<input type="hidden" value="<?php echo $listing->getId() ?>" name="template_id">
<div class="widget" id="template_content_div">
	<div class="head"><h5 class="iList">Listing Content Definition for: <?php echo $listing->getName() ?></h5></div>
			
			<div class="template_content">
				<div>
					Field name
				</div>
				<div style="float:left; margin-right: 20px; margin-bottom: 20px;">
					<input type="text" name="list_field_name" style="height:25px;width: 200px;" value="<?php echo $list_field->getName()?>" id="list_field_name" />
				</div>

			</div>
			
			<div class="template_content">
					<div class="widget" style="margin-top:10px"> 
                  		<div class="head"><h5 class="iPencil">Field value</h5></div>
	                    <textarea class="wysiwyg" rows="5" cols="" id="field_value" name="field_value" ><?php echo $list_field->getValue()?></textarea>
	            	</div> 
            </div>       
	
	<div style="clear: both; margin-bottom: 10px"></div>
</div>
	<div style="float:right; margin-top:20px;">
		<input type="button" id="save" value="Save" class="greyishBtn submitForm" >
	</div>
	<div style="float:right; margin-top:20px;">
		<?php // if($deletable == true){?>
		 <!-- 	<input type="button" id="delete" value="Delete" class="redBtn submitForm"> -->
		<?php // }?>
	</div>	
	<div style="clear: both;"></div>
</form>

<script>


$("#save").click(function (event){
    submitForm();
})

/*$("form#listing_content_form").submit(function (event){
    event.preventDefault();
    submitForm();
})*/


function submitForm(){
    if ($("#list_field_name").attr("value") != "" && $("#field_value").attr("value") != ""){
    	$("form#listing_content_form").attr('action', '<?php echo url_for('listing_content/'.($list_field->isNew() ? 'create' :'update').(!$list_field->isNew() ? '?listing_id='.$listing->getId().'&field_id='.$list_field->getId() : '?listing_id='.$listing->getId()))?>');
    	$("form#listing_content_form").submit();
    }
    
}


$('form').jqTransform({imgPath:'../images/forms'});



</script>